package com.lzx.study.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class ChatModelController {
    @Resource
    private ChatModel chatModel;
    @GetMapping("/hello/doChat")
    public String doChat(@RequestParam(name = "msg", defaultValue = "你是谁") String msg) {
        String result = chatModel.call(msg);
        return result;
    }
    @GetMapping("/hello/doChatStream")
    public Flux<String> doChatStream(@RequestParam(name = "msg", defaultValue = "你是谁") String msg) {
        Flux<String> stream = chatModel.stream(msg);
        return stream;
    }
}
